package com.test.ui
{
	import laya.display.Stage;
	import laya.display.Text;
	import laya.net.Loader;
	import laya.utils.Browser;
	import laya.utils.Handler;
	import laya.webgl.WebGL;
	import laya.display.Sprite;
	
	
	public class Background extends Sprite
	{
		//背景1
		private var bg1:Sprite;
		
		//背景2
		private var bg2:Sprite;
		
		
		
		public function Background() {
			super();
			
			this.bg1 = new Sprite();
			this.bg1.loadImage("res/background.png");
			this.addChild(this.bg1);
			
			this.bg2 = new Sprite();
			this.bg2.loadImage("res/background.png");
			this.bg2.pos(0,-852);
			this.addChild(this.bg2);
			
			
			Laya.timer.frameLoop(1,this,onMyLoop);
		}
		
		private   function onMyLoop():void
		{
			//背景容器每帧向下移动1像素
			this.y += 1;
			
			//如果背景图到了下面不可见，立即调整位置到上面循环显示
			if (this.bg1.y + this.y >= 852) {
				this.bg1.y -= 852 * 2;
			}
			if (this.bg2.y + this.y >= 852) {
				this.bg2.y -= 852 * 2;
			}
			
		}
	}
}